package main

import (
	"eostask/routes"

	"github.com/gin-gonic/gin"
	"github.com/go-session/gin-session"
)

func main() {
	//创建gin对象
	r := gin.Default()

	r.Use(ginsession.New()) //Use(ginsession.New())
	// 静态文件c
	r.StaticFile("/", "./dist/index.html")
	r.StaticFile("/index", "./dist/index.html")
	r.Static("/static", "./dist/static")

	// 设置路由
	// http://localhost:9090/ping GET
	r.GET("/ping", routes.Ping)
	// 路由服务规则
	r.POST("/login", routes.Login)
	// 注册服务规则
	r.POST("/register", routes.Register)
	// 任务发布服务规则
	r.POST("/issue", routes.IssueTask)
	// 任务变更服务规则
	r.POST("/update", routes.UpdateTask)

	// 任务列表服务规则
	r.GET("/tasklist", routes.TaskList)
	r.GET("/balance", routes.BalanceOf)
	r.GET("/logout", routes.LogOut)

	// 启动http服务器
	r.Run(":9090") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
